from django.db import models

# Create your models here.
from django.db import models
from django.contrib.auth.models import User

# 作者模型
class Author(models.Model):
    name = models.CharField(max_length=100)
    bio = models.TextField()  # 作者简介
    def __str__(self):
        return self.name

# 图书模型
class Book(models.Model):
    title = models.CharField(max_length=200)
    author = models.ForeignKey(Author, on_delete=models.CASCADE)
    borrower = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)  # 借阅者
    def __str__(self):
        return self.title